import requests
import threading
import time

url_list = ["https://www.cnblogs.com/#p{}".format(i) for i in range(1, 50 + 1)]


def get_date(url):
    res = requests.request("GET", url)
    with open("./file/{}.html".format(str(url).split("#")[-1]), 'w', encoding='utf-8') as f:
        f.write(res.text)
    print(url)


def run():
    thread_list = []
    for i in url_list:
        thread = threading.Thread(target=get_date, args=(i,))
        thread_list.append(thread)

    for thread in thread_list:
        thread.start()

    for thread in thread_list:
        thread.join()


if __name__ == '__main__':
    s = time.time()
    run()
    e = time.time()
    print(e - s)
